<!DOCTYPE html><html><head>
      <title>hello_world</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="file:////home/zuoshiyu/.vscode/extensions/shd101wyy.markdown-preview-enhanced-0.3.11/node_modules/@shd101wyy/mume/dependencies/katex/katex.min.css">
      
      
      
      
      
      
      
      
      

      <style> 
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */
 
      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview   ">
      <h1 class="mume-header" id="cmake%E7%9A%84hello-world">cmake&#x7684;Hello World</h1>

<h2 class="mume-header" id="%E6%B2%A1%E6%9C%89%E5%BC%95%E8%A8%80">&#x6CA1;&#x6709;&#x5F15;&#x8A00;</h2>

<h3 class="mume-header" id="%E5%85%88%E7%BC%96%E5%86%99%E4%B8%80%E4%B8%AAmainc%E6%96%87%E4%BB%B6">&#x5148;&#x7F16;&#x5199;&#x4E00;&#x4E2A;<code>main.c</code>&#x6587;&#x4EF6;</h3>

<pre data-role="codeBlock" data-info="c" class="language-c"><span class="token comment">// main.c</span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span>
<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;Hello World from t1 Main!\n&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><h3 class="mume-header" id="%E7%84%B6%E5%90%8E%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAcmakeliststxt%E6%96%87%E4%BB%B6%E5%86%99%E5%85%A5%E5%A6%82%E4%B8%8B%E5%86%85%E5%AE%B9">&#x7136;&#x540E;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>CMakeLists.txt</code>&#x6587;&#x4EF6;,&#x5199;&#x5165;&#x5982;&#x4E0B;&#x5185;&#x5BB9;</h3>

<pre data-role="codeBlock" data-info="c" class="language-c"><span class="token function">PROJECT</span> <span class="token punctuation">(</span>HELLO<span class="token punctuation">)</span>
<span class="token function">SET</span> <span class="token punctuation">(</span>SRC_LIST main<span class="token punctuation">.</span>c<span class="token punctuation">)</span>
<span class="token function">MESSAGE</span><span class="token punctuation">(</span>STATUS <span class="token string">&quot;This is BINARY dir &quot;</span> $<span class="token punctuation">{</span>HELLO_BINARY_DIR<span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token function">MESSAGE</span><span class="token punctuation">(</span>STATUS <span class="token string">&quot;This is SOURCE dir &quot;</span> $<span class="token punctuation">{</span>HELLO_SOURCE_DIR<span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token function">ADD_EXECUTABLE</span><span class="token punctuation">(</span>hello $<span class="token punctuation">{</span>SRC_LIST<span class="token punctuation">}</span><span class="token punctuation">)</span>
</pre><h3 class="mume-header" id="%E8%BF%90%E8%A1%8C%E5%A6%82%E4%B8%8B%E5%91%BD%E4%BB%A4">&#x8FD0;&#x884C;&#x5982;&#x4E0B;&#x547D;&#x4EE4;</h3>

<blockquote>
<p><code>cmake .</code></p>
</blockquote>
<pre data-role="codeBlock" data-info="txt" class="language-txt"><code>-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- This is BINARY dir /home/zuoshiyu/workspace/cmake/t1
-- This is SOURCE dir /home/zuoshiyu/workspace/cmake/t1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zuoshiyu/workspace/cmake/t1
</code></pre><blockquote>
<p><code>make</code></p>
</blockquote>
<pre data-role="codeBlock" data-info="txt" class="language-txt"><code>[ 50%] Building C object CMakeFiles/hello.dir/main.c.o
[100%] Linking C executable hello
[100%] Built target hello
</code></pre><h3 class="mume-header" id="%E6%9C%80%E5%90%8E%E7%9B%AE%E5%BD%95%E4%B8%8B%E4%BC%9A%E7%94%9F%E6%88%90%E8%BF%99%E4%BA%9B">&#x6700;&#x540E;&#x76EE;&#x5F55;&#x4E0B;&#x4F1A;&#x751F;&#x6210;&#x8FD9;&#x4E9B;</h3>

<pre data-role="codeBlock" data-info="txt" class="language-txt"><code>-rw-r--r-- 1 zuoshiyu zuoshiyu  13K 9&#x6708;  28 10:36 CMakeCache.txt
drwxr-xr-x 5 zuoshiyu zuoshiyu 4.0K 9&#x6708;  28 10:36 CMakeFiles
-rw-r--r-- 1 zuoshiyu zuoshiyu 1.5K 9&#x6708;  28 10:36 cmake_install.cmake
-rw-r--r-- 1 zuoshiyu zuoshiyu  188 9&#x6708;  28 10:23 CMakeLists.txt
-rwxr-xr-x 1 zuoshiyu zuoshiyu 8.2K 9&#x6708;  28 10:36 hello
-rw-r--r-- 1 zuoshiyu zuoshiyu  103 9&#x6708;  28 10:20 main.c
-rw-r--r-- 1 zuoshiyu zuoshiyu 4.7K 9&#x6708;  28 10:36 Makefile
</code></pre><h3 class="mume-header" id="%E8%BF%90%E8%A1%8C%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6hello">&#x8FD0;&#x884C;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;<code>hello</code></h3>

<blockquote>
<p><code>./hello</code></p>
</blockquote>
<p>&#x5C31;&#x4F1A;&#x8F93;&#x51FA;:</p>
<pre data-role="codeBlock" data-info="txt" class="language-txt"><code>Hello World from t1 Main!
</code></pre><hr>
<h2 class="mume-header" id="%E7%AE%80%E5%8D%95%E7%9A%84%E8%A7%A3%E9%87%8A">&#x7B80;&#x5355;&#x7684;&#x89E3;&#x91CA;</h2>

<p><strong>CMakeLists.txt</strong><br>
&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x662F;<code>cmake</code>&#x7684;&#x6784;&#x5EFA;&#x5B9A;&#x4E49;&#x6587;&#x4EF6;,&#x6587;&#x4EF6;&#x540D;&#x662F;&#x5927;&#x5C0F;&#x5199;&#x76F8;&#x5173;&#x7684;.&#x5982;&#x679C;&#x5DE5;&#x7A0B;&#x5B58;&#x5728;&#x8FC7;&#x4E2A;&#x76EE;&#x5F55;,&#x9700;&#x8981;&#x786E;&#x4FDD;&#x6BCF;&#x4E2A;&#x8981;&#x7BA1;&#x7406;&#x7684;&#x76EE;&#x5F55;&#x90FD;&#x5B58;&#x5728;&#x4E00;&#x4E2A;<code>CMakeLists.txt</code>(&#x597D;&#x60E8;&#x554A;,&#x6BCF;&#x4E2A;&#x76EE;&#x5F55;&#x90FD;&#x8981;&#x5199;).</p>
<p><strong>PROJECT</strong><br>
PROJECT(projectname [CXX] [C] [Java])</p>
<p>&#x8FD9;&#x4E2A;&#x547D;&#x4EE4;&#x7528;&#x4E8E;&#x5B9A;&#x4E49;&#x5DE5;&#x7A0B;&#x540D;&#x79F0;,&#x5E76;&#x53EF;&#x6307;&#x5B9A;&#x5DE5;&#x7A0B;&#x652F;&#x6301;&#x7684;&#x8BED;&#x8A00;,&#x652F;&#x6301;&#x7684;&#x8BED;&#x8A00;&#x5217;&#x8868;&#x662F;&#x53EF;&#x4EE5;&#x5FFD;&#x7565;&#x7684;,&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x8868;&#x793A;&#x652F;&#x6301;&#x6240;&#x6709;&#x8BED;&#x8A00;.<br>
&#x8FD9;&#x4E2A;&#x547D;&#x4EE4;&#x9690;&#x5F0F;&#x5B9A;&#x4E49;&#x4E86;&#x4E24;&#x4E2A;cmake&#x53D8;&#x91CF;</p>
<pre class="language-text">&lt;projectname&gt;_BINARY_DIR &amp;&amp; &lt;projectname&gt;_SOURCE_DIR
</pre>
<blockquote>
<p>&#x5728;&#x8FD9;&#x91CC;&#x5C31;&#x662F;<code>HELLO_BINARY_DIR</code>&#x548C;<code>HELLO_SOURCE_DIR</code>,&#x5F53;&#x7136;&#x4E24;&#x8005;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x4E0D;&#x540C;.</p>
</blockquote>
<p>&#x540C;&#x65F6;cmake&#x7CFB;&#x7EDF;&#x4E5F;&#x5E2E;&#x52A9;&#x6211;&#x4EEC;&#x9884;&#x5B9A;&#x4E49;&#x4E86;<code>PROJECT_BINARY_DIR</code>&#x548C;<code>PROJECT_SOURCE_DIR</code>&#x53D8;&#x91CF;.&#x4ED6;&#x4EEC;&#x7684;&#x503C;&#x5206;&#x522B;&#x4E0E;<code>HELLO_BINARY_DIR</code>&#x4E0E;<code>HELLO_SOURCE_DIR</code>&#x4E00;&#x81F4;.<br>
&#x4E3A;&#x4E86;&#x7EDF;&#x4E00;&#x8D77;&#x89C1;,&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;<code>PROJECT_BINARY_DIR</code>&#x548C;<code>PROJECT_SOURCE_DIR</code>.</p>
<p><strong>SET&#x6307;&#x4EE4;&#x7684;&#x8BED;&#x6CD5;</strong><br>
SET (VAR [VALUE] [CACHE TYPE DOSSTRING [FORCE]])</p>
<p>&#x73B0;&#x9636;&#x6BB5;,&#x53EA;&#x9700;&#x8981;&#x4E86;&#x89E3;<code>SET</code>&#x6307;&#x4EE4;&#x53EF;&#x4EE5;&#x7528;&#x4E8E;&#x663E;&#x5F0F;&#x5B9A;&#x4E49;&#x53D8;&#x91CF;.<br>
&#x6BD4;&#x5982;<code>SET (SRC_LIST main.c)</code>&#x5982;&#x679C;&#x6709;&#x591A;&#x4E2A;&#x6E90;&#x6587;&#x4EF6;,&#x53EF;&#x4EE5;&#x5B9A;&#x4E49;&#x6210;:<code>SET (SRC_LIST main.c t1.c t2.c)</code>.</p>
<p><strong>MESSAGE</strong><br>
MESSAGE ([SEND_ERROR | STATUS | FATAL_ERROR] &quot;message to display&quot; ...)</p>
<p>&#x8FD9;&#x4E2A;&#x6307;&#x4EE4;&#x7528;&#x4E8E;&#x5411;&#x7EC8;&#x7AEF;&#x8F93;&#x51FA;&#x7528;&#x6237;&#x5B9A;&#x4E49;&#x7684;&#x4FE1;&#x606F;,&#x5305;&#x542B;&#x4E86;&#x4E09;&#x79CD;&#x7C7B;&#x578B;.</p>
<ul>
<li>SEND_ERROR: &#x4EA7;&#x751F;&#x9519;&#x8BEF;,&#x751F;&#x6210;&#x8FC7;&#x7A0B;&#x88AB;&#x8DF3;&#x8FC7;.</li>
<li>STATUS: &#x8F93;&#x51FA;&#x524D;&#x7F00;&#x4F4D;<code>--</code>&#x7684;&#x4FE1;&#x606F;.</li>
<li>FATAL_ERROR:&#x7ACB;&#x5373;&#x7EC8;&#x6B62;&#x6240;&#x6709;cmake&#x8FC7;&#x7A0B;.</li>
</ul>
<p><strong>ADD_EXECUTABLE</strong><br>
ADD_EXECUTABLE(hello ${SRC_LIST})</p>
<p>&#x5B9A;&#x4E49;&#x4E86;&#x8FD9;&#x4E2A;&#x5DE5;&#x7A0B;&#x4F1A;&#x751F;&#x6210;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x540D;&#x4E3A;hello&#x7684;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;,&#x76F8;&#x5173;&#x7684;&#x6E90;&#x6587;&#x4EF6;&#x662F;SRC_LIST&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x6E90;&#x6587;&#x4EF6;&#x5217;&#x8868;,&#x672C;&#x4F8B;&#x4E2D;&#x4E5F;&#x53EF;&#x4EE5;&#x5199;&#x6210;<br>
<code>ADD_EXECUTABLE(hello main.c)</code>.</p>
<blockquote>
<p><code>${}</code>&#x8FD9;&#x662F;cmake&#x7684;,&#x4F46;&#x662F;&#x5728;<strong>IF</strong>&#x63A7;&#x5236;&#x8BED;&#x53E5;&#x4E2D;&#x9664;&#x5916;,<br>
&#x5728;IF&#x63A7;&#x5236;&#x8BED;&#x53E5;&#x4E2D;,&#x53D8;&#x91CF;&#x662F;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#x540D;&#x5F15;&#x7528;,&#x4E0D;&#x9700;&#x8981;<code>${}</code>,<br>
&#x5982;&#x679C;&#x4F7F;&#x7528;&#x4E86;<code>${}</code>&#x53BB;&#x5F15;&#x7528;&#x53D8;&#x91CF;,&#x5176;&#x5B9E;IF&#x4F1A;&#x53BB;&#x627E;&#x540D;&#x4E3A;<code>${var_name}</code>&#x7684;&#x53D8;&#x91CF;(&#x600E;&#x4E48;&#x53EF;&#x80FD;&#x4F1A;&#x5B58;&#x5728;&#x5462;?)</p>
</blockquote>
<h2 class="mume-header" id="%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95%E8%A7%84%E5%88%99">&#x57FA;&#x672C;&#x8BED;&#x6CD5;&#x89C4;&#x5219;</h2>

<ol>
<li>&#x53D8;&#x91CF;&#x4F7F;&#x7528;<code>${}</code>&#x65B9;&#x5F0F;&#x53D6;&#x503C;,&#x4F46;&#x662F;&#x5728;IF&#x63A7;&#x5236;&#x8BED;&#x53E5;&#x4E2D;&#x662F;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#x540D;</li>
<li>&#x6307;&#x4EE4;(&#x53C2;&#x6570;1 &#x53C2;&#x6570;2)   &#x53C2;&#x6570;&#x4F7F;&#x7528;&#x62EC;&#x5F27;&#x62EC;&#x8D77;,&#x53C2;&#x6570;&#x4E4B;&#x95F4;&#x4F7F;&#x7528;&#x7A7A;&#x683C;&#x6216;&#x5206;&#x597D;&#x5206;&#x5F00;.</li>
<li>&#x6307;&#x4EE4;&#x662F;&#x5927;&#x5C0F;&#x5199;&#x65E0;&#x5173;&#x7684;, &#x53C2;&#x6570;&#x548C; &#x53D8;&#x91CF;&#x662F;&#x5927;&#x5C0F;&#x5199;&#x76F8;&#x5173;&#x7684;,&#x4F46;&#x662F;&#x63A8;&#x8350;&#x5168;&#x90E8;&#x4F7F;&#x7528;&#x5927;&#x5199;&#x6307;&#x4EE4;.</li>
</ol>
<blockquote>
<p>&#x4EE5;&#x4E0A;&#x9762;&#x7684;ADD_EXECUTABLE&#x4E3A;&#x4F8B;,&#x5982;&#x679C;&#x5B58;&#x5728;&#x53E6;&#x5916;&#x4E00;&#x4E2A;<code>func.c</code>&#x6587;&#x4EF6;,&#x5C31;&#x53EF;&#x4EE5;&#x5199;&#x6210;:<br>
ADD_EXECUTABLE(hello main.c func.c) or ADD_EXECUTABLE(hello main.c;func.c)</p>
<blockquote>
<p>&#x8FD9;&#x91CC;&#x9700;&#x8981;&#x7279;&#x522B;&#x89E3;&#x91CA;&#x7684;&#x662F;PROJECT_NAME <code>HELLO</code> &#x548C; &#x751F;&#x6210;&#x7684;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;<code>Hello</code>&#x662F;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x5173;&#x7CFB;&#x7684;.</p>
</blockquote>
</blockquote>
<h2 class="mume-header" id="%E5%85%B3%E4%BA%8E%E8%AF%AD%E6%B3%95%E7%9A%84%E7%96%91%E6%83%91">&#x5173;&#x4E8E;&#x8BED;&#x6CD5;&#x7684;&#x7591;&#x60D1;</h2>

<p>cmake&#x7684;&#x8BED;&#x6CD5;&#x8FD8;&#x662F;&#x6BD4;&#x8F83;&#x7075;&#x6D3B;&#x800C;&#x4E14;&#x8003;&#x8651;&#x5230;&#x5404;&#x79CD;&#x60C5;&#x51B5;, &#x6BD4;&#x5982;:<br>
<code>SET (SRC_LIST main.c)</code>&#x4E5F;&#x53EF;&#x4EE5;&#x5199;&#x6210;<code>SET (SRC_LIST &quot;main.c&quot;)</code>&#x8FD9;&#x662F;&#x6CA1;&#x6709;&#x533A;&#x522B;&#x7684;.<br>
&#x4F46;&#x662F;&#x5982;&#x679C;&#x6709;&#x4E00;&#x4E2A;&#x6E90;&#x6587;&#x4EF6;&#x540D;&#x5B57;&#x662F;<code>fu k.c</code>(&#x6587;&#x4EF6;&#x540D;&#x91CC;&#x9762;&#x6709;&#x7A7A;&#x683C;)<br>
&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#x5C31;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x53CC;&#x5F15;&#x53F7;,<code>SET (SRC_LIST &quot;fu k.c&quot;)</code></p>
<h2 class="mume-header" id="%E6%B8%85%E7%90%86%E5%B7%A5%E7%A8%8B">&#x6E05;&#x7406;&#x5DE5;&#x7A0B;</h2>

<p><code>make clean</code>&#x5373;&#x53EF;&#x5BF9;&#x6784;&#x5EFA;&#x7ED3;&#x679C;&#x8FDB;&#x884C;&#x6E05;&#x7406;.</p>
<h2 class="mume-header" id="%E5%95%A5%E5%95%A5%E5%95%A5%E7%9A%84">&#x5565;?&#x5565;?&#x5565;?&#x7684;</h2>

<p>&#x6709;&#x4EBA;&#x4F1A;&#x5C1D;&#x8BD5;&#x8FD0;&#x884C;<code>make distclean</code>&#x6E05;&#x7406;&#x6784;&#x5EFA;&#x8FC7;&#x7A0B;&#x4E2D;&#x4EA7;&#x751F;&#x7684;&#x4E2D;&#x95F4;&#x6587;&#x4EF6;.<br>
&#x4F46;&#x662F;cmake&#x5E76;&#x4E0D;&#x652F;&#x6301;<code>make distclean</code>,&#x5B98;&#x65B9;&#x89E3;&#x91CA;&#x662F;:<br>
&#x56E0;&#x4E3A;CMakeLists.txt&#x53EF;&#x4EE5;&#x6267;&#x884C;&#x811A;&#x672C;&#x5E76;&#x901A;&#x8FC7;&#x811A;&#x672C;&#x751F;&#x6210;&#x4E00;&#x4E9B;&#x4E34;&#x65F6;&#x6587;&#x4EF6;,&#x4F46;&#x662F;&#x5374;&#x6CA1;&#x6709;&#x529E;&#x6CD5;&#x6765;&#x8DDF;&#x8E2A;&#x8FD9;&#x4E9B;&#x4E34;&#x65F6;&#x6587;&#x4EF6;&#x5230;&#x5E95;&#x662F;&#x54EA;&#x4E9B;.<br>
&#x56E0;&#x6B64;,&#x6CA1;&#x6709;&#x529E;&#x6CD5;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x53EF;&#x9760;&#x7684;<code>make distclean</code>&#x65B9;&#x6848;.</p>
<p>&#x540C;&#x65F6;,cmake&#x5F3A;&#x70C8;&#x63A8;&#x8350;&#x4F7F;&#x7528;&#x5916;&#x90E8;&#x6784;&#x5EFA;(out-of-source build).</p>
<h2 class="mume-header" id="%E5%86%85%E9%83%A8%E6%9E%84%E5%BB%BA%E4%B8%8E%E5%A4%96%E9%83%A8%E6%9E%84%E5%BB%BA">&#x5185;&#x90E8;&#x6784;&#x5EFA;&#x4E0E;&#x5916;&#x90E8;&#x6784;&#x5EFA;</h2>

<p>&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x5C31;&#x662F;&#x5185;&#x90E8;&#x7F16;&#x8BD1;,&#x5B83;&#x4F1A;&#x751F;&#x6210;&#x4E00;&#x4E9B;&#x65E0;&#x6CD5;&#x81EA;&#x52A8;&#x5220;&#x9664;&#x7684;&#x4E2D;&#x95F4;&#x6587;&#x4EF6;</p>
<p>&#x63A5;&#x4E0B;&#x6765;&#x7684;&#x64CD;&#x4F5C;&#x5C06;&#x4F1A;&#x628A;&#x524D;&#x9762;&#x7684;<code>&#x5185;&#x90E8;&#x6784;&#x5EFA;</code>&#x53D8;&#x6210;<code>&#x5916;&#x90E8;&#x6784;&#x5EFA;</code>:</p>
<ol>
<li>&#x9996;&#x5148;,&#x6E05;&#x695A;&#x76EE;&#x5F55;&#x4E2D;&#x9664;<code>main.c</code>,<code>CMakeLists.txt</code>&#x4E4B;&#x5916;&#x7684;&#x6240;&#x6709;&#x4E2D;&#x95F4;&#x6587;&#x4EF6;.(&#x5173;&#x952E;&#x662F;CMakeCache.txt)</li>
<li>&#x5728;&#x76EE;&#x5F55;&#x4E0B;&#x5EFA;&#x7ACB;&#x4E00;&#x4E2A;<code>build</code>&#x76EE;&#x5F55;,&#x5F53;&#x7136;&#x8FD9;&#x4E2A;&#x53EF;&#x4EE5;&#x5EFA;&#x7ACB;&#x5728;&#x4EFB;&#x4F55;&#x5730;&#x65B9;,&#x751A;&#x81F3;&#x5DE5;&#x7A0B;&#x4E4B;&#x5916;.</li>
<li>&#x8FDB;&#x5165;<code>build</code>&#x76EE;&#x5F55;,&#x8FD0;&#x884C;<code>cmake ..</code>(&#x5176;&#x5B9E;&#x5C31;&#x662F;<code>cmake &lt;&#x5DE5;&#x7A0B;&#x7684;&#x8DEF;&#x5F84;&gt;</code>,&#x8DEF;&#x5F84;&#x53EF;&#x4EE5;&#x662F;&#x76F8;&#x5BF9;&#x7684;,&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7EDD;&#x5BF9;&#x7684;.)</li>
<li>&#x8FD0;&#x884C;<code>make</code>&#x6784;&#x5EFA;&#x5DE5;&#x7A0B;,&#x5C31;&#x4F1A;&#x5728;&#x5F53;&#x524D;&#x76EE;&#x5F55;(build&#x76EE;&#x5F55;)&#x4E2D;&#x83B7;&#x53D6;&#x76EE;&#x6807;&#x6587;&#x4EF6;<code>hello</code>.</li>
</ol>
<p><em>out-of-source</em>&#x5916;&#x90E8;&#x7F16;&#x8BD1;,&#x4E00;&#x4E2A;&#x6700;&#x5927;&#x7684;&#x597D;&#x5904;&#x5C31;&#x662F;,&#x5BF9;&#x4E8E;&#x539F;&#x6709;&#x5DE5;&#x7A0B;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x5F71;&#x54CD;,</p>

      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>